function inputsEvents () {
    $('.custom-checkbox i').on('click', function(e) {
        e.preventDefault();
        $(this).next('label').trigger('click');
    });

    $('.custom-radio i').on('click', function(e) {
        e.preventDefault();
        $(this).next('label').trigger('click');
    });
}

function invoiceCheck () {
    $('#invoice-cb').change(function() {
        if ( $(this).is(':checked') ) {
            $('#post-addr, #post-tips').removeClass('hide');
        }else{
            $('#post-addr, #post-tips').addClass('hide');
        }
    });
}

function addPeople () {
    // TODO: 最多添加十个人
    $('#add-new-people').on('click', function(e) {
        if (count >= 10) {
            alert('最多添加10人');
            return
        };
        e.preventDefault();
        var obj = $("#insured").clone();
        obj.attr("id", "insured"+count);
        obj.find("table").attr("id", "insured"+count);
        obj.find("input").val('');
        obj.find("select[name='recognizee_relation']").val(0);
        if (obj.find("select[name='recognizee_credentials_category']").val() == 1) {
            obj.find(".birth_date").show();
        } else {
            obj.find(".birth_date").hide();
        };
        obj.insertBefore('#add-new-people');
        count += 1;
    });
}


inputsEvents();
invoiceCheck();
addPeople();
